{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from sklearn.metrics import classification_report\n",
    "from sklearn import preprocessing\n",
    "from sklearn import linear_model\n",
    "# 数据是否需要标准化\n",
    "scale = False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3X+wHWWd5/H3NyQYo2gwCQomuRcHFhFMIkkRKawVBn/ErAvrFlPqRisKVkoU80PdAcyO9zq71I7jDpgs41BZsWQ2kZlZZlELZQGVLXYKZLyhAgQRQQnxEhZCIIiFrAn57h99Djn35PzoPqd/PN39eVV13Xv69unznNPnPt/u5/s8T5u7IyIi9TOt6AKIiEgxFABERGpKAUBEpKYUAEREakoBQESkphQARERqSgFARKSmFABERGpKAUBEpKamF12AXubOneujo6NFF0NEpDS2b9/+jLvPi7Nt0AFgdHSUiYmJooshIlIaZvZ43G3VBCQiUlMKACIiNRU7AJjZt8zsaTPb2bJu3MyeMLMdjWVll+euMLOHzexRM7s8jYKLiMhwkuQAvg1cA/xt2/qr3f2/dHuSmR0F/DXwXmAS+JmZfd/df56wrAAcOHCAyclJXnrppUGeXgkzZ85k/vz5zJgxo+iiiEiJxQ4A7n6nmY0O8BpnAo+6+68BzOzvgAuAgQLA5OQkxxxzDKOjo5jZILsoNXdn3759TE5OcuKJJxZdHBEpsTRyAJea2f2NJqJjO/z9zcBvWh5PNtYN5KWXXmLOnDm1rPwBzIw5c+bU+gqobrZtg9FRmDYt+rltW9ElkqoYNgD8D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Onuvgj4JXBFweWJayfwb4E7iy5IL2Z2FPDXwAeAtwEfNbO3FVuqvr4NrCi6EAkdBL7g7qcC7wQ+W4LPGeD/AX/s7ouBJcAKM3tn1i9aigAAXA38KVCKhIW7/7bl4WsoQbnd/TZ3P9h4+FNgfpHlicvdH3L3MgwWPBN41N1/7e5/AP4OuKDgMvXk7ncCzxZdjiTc/Ul3v7fx+wvAQ8Cbiy1Vfx75XePhjMaSeb0RfAAws/OBJ9z9vqLLkoSZXWlmvwFWUY4rgFYXAbcUXYiKeTPwm5bHk5SgYiozMxsF3gHcU2xJ4jGzo8xsB/A0cLu7Z17uIEYCm9mPgDd1+NNG4EvA+/ItUX+9yuzu33P3jcBGM7sCuBQYy7WAHfQrc2ObjUSX0dvyLFsvccpdAp1uYRb8lWFZmdlrgX8E1rddkQfL3V8GljTybzeZ2enunmn+JYgA4O7v6bTezN4OnAjcZ9EtAOcD95rZme7+f3Ms4hG6lbmD7wA/IIAA0K/MZrYa+CBwngfUPzjBZx2ySWBBy+P5wJ6CylJpZjaDqPLf5u7/s+jyJOXu+83sfxPlXzINAEE3Abn7A+5+nLuPuvso0T/RGUVX/v2Y2cktD88HflFUWeIysxXAZcD57v5i0eWpoJ8BJ5vZiWZ2NPAR4PsFl6lyLDpTvA54yN2vKro8cZnZvGbPOzN7NfAecqg3gg4AJfYXZrbTzO4nar4qQ1e0a4BjgNsb3VevLbpAcZjZh8xsEjgL+IGZ3Vp0mTppJNgvBW4lSkz+g7s/WGypejOzG4C7gVPMbNLMLi66TDGcDXwc+OPG93iHma0sulAxHA/c0agzfkaUA7g56xfVSGARkZrSFYCISE0pAIiI1JQCgIhITSkAiIjUlAKAiEhNKQCIiNSUAoCISE0pAIiI1NT/B9TaoxvjcU4gAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 载入数据\n",
    "data = np.genfromtxt(\"LR-testSet.csv\", delimiter=\",\")\n",
    "x_data = data[:,:-1]\n",
    "y_data = data[:,-1]\n",
    "    \n",
    "def plot():\n",
    "    x0 = []\n",
    "    x1 = []\n",
    "    y0 = []\n",
    "    y1 = []\n",
    "    # 切分不同类别的数据\n",
    "    for i in range(len(x_data)):\n",
    "        if y_data[i]==0:\n",
    "            x0.append(x_data[i,0])\n",
    "            y0.append(x_data[i,1])\n",
    "        else:\n",
    "            x1.append(x_data[i,0])\n",
    "            y1.append(x_data[i,1])\n",
    "\n",
    "    # 画图\n",
    "    scatter0 = plt.scatter(x0, y0, c='b', marker='o')\n",
    "    scatter1 = plt.scatter(x1, y1, c='r', marker='x')\n",
    "    #画图例\n",
    "    plt.legend(handles=[scatter0,scatter1],labels=['label0','label1'],loc='best')\n",
    "    \n",
    "plot()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,\n",
       "          intercept_scaling=1, max_iter=100, multi_class='ovr', n_jobs=1,\n",
       "          penalty='l2', random_state=None, solver='liblinear', tol=0.0001,\n",
       "          verbose=0, warm_start=False)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "logistic = linear_model.LogisticRegression()  # 线性回归模型下的逻辑回归\n",
    "logistic.fit(x_data, y_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.44732445, -0.58003724]])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "logistic.coef_ # 取参数[0][0]，是二维的注意"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAAB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DfsT542Xk7rs3bu3T9rlrqQTT548mVgsxldvv703x/7888+HZcvg6NGzz+7RR88+03I8u5CUj/aNiAXKLQYQVQLsowwKbqSaqiq7du3qo+zff/99wMmxv/jii1N89o2Njc6kJdlcCSNHwne+k3yR4D27Sv99BTjGZjEAIxQjJf0OwBaaatrT08Pbb7/dR9kfPnwYcCYtufTSS7n22muJxWI0NzczZ84chg8f3vdkhbgSgvbsIuQDL4ooxdjyTRfyY7E00Oiydq3q0KGp2YZDh5Y/1TNbqmlXV5e2t7frT37yE73//vv1E5/4hA4fPrw37bKqqkpjsZjeeeed+vjjj+urr76qH374YWEXLyRdN32bX6mZyTInZE1fjzIh+P5YGqgRdII00vf06dNs2bKlz6QlJ0+eBOCcc87JOGnJ4MGDS794Pq6EoLW4Kz1VNGjPIw0rBWEEHr9q/Zw8ebLPpCXt7e29k5YMHz6cpqams8q+qYnpyZOWuOnrzkeR5srq8kPpJr5/gH3gZSHAMRCLARiBp7Y2cw/AzSkgjh07xsaNG1Na9q+//nrvpCXnnXcesViM+++/v1fhX3TRRWcnLVm+HNavP5v14WZLL9903SBlnSRavitXwgMPpO4Lqw+8WEIQY8sHMwCGL7hd6+fIkSN9cuzffPNNEj3c888/n+bmZq6//vpeZV9bW5t90hKv870LSddN7EvuKfjR8k/cj//4D9iwARobz77aOJNwkm+wwI/FgsDRpthaP++//74+//zzumLFCr3xxht18uTJvcFZQGtra/WGG27Q7373u/rcc8/pnj17ihOwHDWV8gnuBqW2UzY5zpxxXpctK48MudYNCwIb0UBV2b17d5+0y927d/ceM3Xq1JTgbFNTE2PHjnVTCH993UGMAWS6H+XwgQc8+BoULAZghA5V5d133+2j7A8cOAA4OfYzZszgqquuShlQNXLkSC+F8j/fO0gju/28H1675CqVfLsKfizmAoom3d3dunXrVm1tbdUHH3xQr7rqKh05cmSvC2fQoEHa2Niod9xxhz722GP6yiuv6PHjx8srZNDyvf12fQThfgTFFRZwKMAFZD0Aw1O6urqcSUuSWvUbNmzgww8/BGDI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0SkXUQ24bitApuyBjwGDAdejKetPuG3QNkQkS+KSAdwBfBvIvJrv2VKJh5Mvwf4NU6Q8l9UdYu/UmVHRJ4C/gBMF5EOEfma3zLl4ErgNuDP47/TDSIy32+hsjABeCn+//8TTgzgOa8vaiOBDcMwKhTrARiGYVQoZgAMwzAqFDMAhmEYFYoZAMMwjArFDIBhGEaFYgbAMAyjQjEDYBiGUaGYATAMw6hQ/j8JEx7ChvDpxwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "if scale == False:\n",
    "    # 画图决策边界\n",
    "    plot()\n",
    "    x_test = np.array([[-4],[3]])\n",
    "    y_test = (-logistic.intercept_ - x_test*logistic.coef_[0][0])/logistic.coef_[0][1] # (-w0-xw1)/w2\n",
    "    plt.plot(x_test, y_test, 'k')\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "             precision    recall  f1-score   support\n",
      "\n",
      "        0.0       0.92      1.00      0.96        47\n",
      "        1.0       1.00      0.92      0.96        53\n",
      "\n",
      "avg / total       0.96      0.96      0.96       100\n",
      "\n"
     ]
    }
   ],
   "source": [
    "predictions = logistic.predict(x_data)\n",
    "\n",
    "print(classification_report(y_data, predictions))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
